package com.gitee.feizns.quickstart.ding.talk.api.v10.yida.forms.instances;

import com.aliyun.dingtalkyida_1_0.Client;
import com.aliyun.dingtalkyida_1_0.models.BatchGetFormDataByIdListHeaders;
import com.aliyun.dingtalkyida_1_0.models.BatchGetFormDataByIdListRequest;
import com.aliyun.dingtalkyida_1_0.models.BatchGetFormDataByIdListResponse;
import com.aliyun.dingtalkyida_1_0.models.BatchGetFormDataByIdListResponseBody;
import com.aliyun.teautil.models.RuntimeOptions;
import com.gitee.feizns.quickstart.ding.talk.client.Clients;

import java.util.List;

/**
 * 批量获取表单实例数据（/v1.0/yida/forms/instances/ids/query）
 * 接口路径：<a href="https://open.dingtalk.com/document/orgapp/obtain-multiple-form-instance-data">批量获取表单实例数据（/v1.0/yida/forms/instances/ids/query）</a>
 * @link <a href="https://open.dingtalk.com/document/orgapp/obtain-multiple-form-instance-data">服务端API 宜搭应用开发 表单 批量获取表单实例数据</a>
 * @author feizns
 * @since 2024/3/24
 */
public class IdsQuery {

    /**
     * 请求头
     * @param accessToken 访问令牌
     * @return {@link BatchGetFormDataByIdListHeaders}
     */
    public static BatchGetFormDataByIdListHeaders headers(String accessToken) {
        BatchGetFormDataByIdListHeaders headers = new BatchGetFormDataByIdListHeaders();
        headers.xAcsDingtalkAccessToken = accessToken;
        return headers;
    }

    /**
     * 执行
     * @param accessToken 访问令牌
     * @param req 要求
     * @return {@link List}<{@link BatchGetFormDataByIdListResponseBody.BatchGetFormDataByIdListResponseBodyResult}>
     * @throws Exception 例外
     */
    public static List<BatchGetFormDataByIdListResponseBody.BatchGetFormDataByIdListResponseBodyResult> execute(String accessToken, BatchGetFormDataByIdListRequest req) throws Exception {
        Client client = Clients.get(Client.class);
        BatchGetFormDataByIdListHeaders headers = headers(accessToken);
        BatchGetFormDataByIdListResponse data = client.batchGetFormDataByIdListWithOptions(req, headers, new RuntimeOptions());
        return data.getBody().getResult();
    }

}
